<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="bolao" />
    <g:set var="entityName" value="${message(code: 'match.label', default: 'Match')}" />
    <title><g:message code="default.list.label" args="[entityName]" /></title>
  </head>
  <body>
  <div class="body">
    <h1 class="title"><g:message code="default.list.label" args="[entityName]" /></h1>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>
    <g:if test="${!groups}">
      <g:set var="groupEntityName" value="${message(code: 'group.label', default: 'Group')}" />
      <p><g:message code="default.any.not.found.message" args="[groupEntityName]" /></p>
    </g:if>
    <g:each in="${groups}" status="i" var="group">
      <br/>
      <h3>${message(code:'group.label', default: 'Group')} ${group.name}</h3>
      <div class="list">
        <table class="table center">
          <thead>
            <tr>
              <th width="10px"><g:message code="match.matchNumber.label"/></th>
              <th><g:message code="match.matchDate.label"/></th>
              <th><g:message code="match.venue.label"/></th>
              <th colspan="5" style="text-align: center"><g:message code="match.result.label"/></th>
          </tr>
          </thead>
          <tbody>
          <g:each in="${matches}" status="j" var="match">
            <g:if test="${group == match.team1.group}">
              <tr class="${(j % 2) == 0 ? 'odd' : 'even'}">
                <td>
              <g:ifAnyGranted role="ROLE_ADMIN,ROLE_SUPERVISOR"><g:link action="show" id="${match.id}">${match?.matchNumber}</g:link></g:ifAnyGranted>
              <g:ifNotGranted role="ROLE_ADMIN,ROLE_SUPERVISOR">${match?.matchNumber}</g:ifNotGranted>
              </td>
              <td><g:formatDate date="${match.matchDate}" format="dd/MM/yyyy HH:mm"/></td>
              <td>${match?.venue}</td>
              <td>
                <g:if test="${match?.team1?.flagImage?.size() > 0}">
                 <img src="<g:createLink controller='team' action='renderFlagImage' id='${match?.team1?.id}'/>"/>
               </g:if>
                ${match?.team1?.name}
              </td>
              <td>${match?.score1 ?: '___'}</td>
              <td>x</td>
              <td>${match?.score2 ?: '___'}</td>
              <td>
                ${match?.team2?.name}
                <g:if test="${match?.team2?.flagImage?.size() > 0}">
                 <img src="<g:createLink controller='team' action='renderFlagImage' id='${match?.team2?.id}'/>"/>
               </g:if>
             </td>
              </tr>
            </g:if>
          </g:each>
          </tbody>
        </table>
      </div>
    </g:each>
  </div>
  <div id="sidebar">
    <div id="ranking" class="boxed">
      <h2><g:message code="ranking"/></h2>
      <div class="content">
        <ol>
          <li><a href="#">Fulano</a> <i>(35)</i></li>
          <li class="active"><a href="#">Cliclano</a> <i>(20)</i></li>
          <li><a href="#">Beltrano</a> <i>(10)</i></li>
        </ol>
      </div>
    </div>
  </div>
</body>
</html>
